<?php
/*
	插件概览
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
if($_RQ['op']=='get'){
	$return['set']=$this->plugin_setting('setting');
	$merchid=intval($_RQ['merchid']);
	if($_SESSION['os']=='windows'){
		$return['session_id']=session_id();
	}
	if($_SESSION['uid']){
		//exi('','error','jy_cashier/manage.index/');
	}
	$_SESSION['logout_forward']='jy_cashier/manage.login/';
	$_SESSION['forward_url']='jy_cashier/manage.index/'; 
	$return['forward_url']=base64_encode($_SESSION['forward_url']);
	$return['info']['forward']='jy_cashier/manage.index//merchid='.$merchid; 
	set_html('title','登录收银台');
	exi($return);
}
if($_RQ['op']=='post'){
	$post=get_postdata();
	$user=pdo_get('jy_cashier_user',array('uniacid'=>$_SESSION['uniacid'],'username'=>$post['username']));
	if(!$user || $post['pwd']!=base64_decode($user['password'])){
		exi('用户名或密码错误','error');
	}
	if(!$user['mid']){
		exi('该收银台没有绑定：收款微信号！无法登录！','error');
	}
	$member=pdo_get('core_members',array('id'=>$user['mid'],'uniacid'=>$_SESSION['uniacid']),array('id'));
	if(empty($member)){
		exi('该收银台绑的收款微信号异常！无法登录！','error');		
	}
	$_SESSION['userid']=$user['id'];
	$_SESSION['uid']=$user['mid'];
	$_SESSION['merchid']=$user['merchid'];
	$_SESSION['member']['username']=$user['username'];
	$url=custom_url('jy_cashier/manage.index/',true);
	exi('登陆成功','',$url);
	
}
